package com.wzy.authority.mapper;

import com.wzy.authority.domain.SysRolePermission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @program: authorityManagement
 * @description: 角色权限链接表服务实现类
 * @author: 1
 * @create: 2020-03-14 20:14
 **/
public interface SysRolePermissionMapper {
    /**
     * 根据组件删除数据
     * @param roleid
     * @param permissionid
     * @return
     */
    int deleteByPrimaryKey(@Param("roleid") Integer roleid, @Param("permissionid") Integer permissionid);

    /**
     * 插入数据
     * @param record
     * @return
     */
    int insert(SysRolePermission record);

    /**
     * 选择性插入数据
     * @param record
     * @return
     */
    int insertSelective(SysRolePermission record);

    /**
     * 批量保存权限数据
     * @param permissionIds
     * @param roleId
     * @return
     */
    int saveList(  @Param("permissionIds") List<Integer> permissionIds ,@Param("roleId") Integer roleId);


    /**
     * 根据角色id删除所有的权限信息
     * @param roleId
     */
    @Delete("delete from sys_role_permission where roleId = #{roleId}")
    void deleteByRoleId(Integer roleId);


    /**
     * 根据角色id查询数据
     * @param roleId  角色id
     * @return
     */
    @Select("select *  from sys_role_permission where roleId = #{roleId}")
    List<SysRolePermission> selectRolePermissionById(Integer roleId);
}